package com.aaa.vegetablemarketexpress.config;

import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;
import java.io.File;

/**
 * 创建上传目录
 * @author ：xih
 */
@Configuration
public class UploadDirConfig {

    @PostConstruct
    public void initUploadDirs() {
/*        // 获取项目根路径
        String projectPath = System.getProperty("user.dir");

        // 定义需要创建的目录
        String[] uploadDirs = {
                projectPath + "/uploads/business-licence/",
                projectPath + "/uploads/avatar/",
                projectPath + "/uploads/id-photo/",
                projectPath + "/uploads/goodsImage/",
                projectPath + "/uploads/shopLogo/"
        };

        // 创建目录
        for (String dirPath : uploadDirs) {
            File dir = new File(dirPath);
            if (!dir.exists()) {
                if (dir.mkdirs()) {
                    System.out.println("成功创建上传目录: " + dirPath);
                } else {
                    System.err.println("创建上传目录失败: " + dirPath);
                }
            }
        }*/
    }
}
//package com.aaa.vegetablemarketexpress.config;
//
//import org.springframework.context.annotation.Configuration;
//
//import javax.annotation.PostConstruct;
//import java.io.File;
//
///**
// * 创建上传目录
// * @author ：xih
// */
//@Configuration
//public class UploadDirConfig {
//
//    @PostConstruct
//    public void initUploadDirs() {
//        // 获取项目根路径
//        String projectPath = System.getProperty("user.dir");
//
//        // 定义需要创建的目录
//        String[] uploadDirs = {
//                projectPath + "/uploads/business-licence/",
//                projectPath + "/uploads/avatar/",
//                projectPath + "/uploads/id-photo/",
//                projectPath + "/uploads/goodsImage/"
//        };
//
//        // 创建目录
//        for (String dirPath : uploadDirs) {
//            File dir = new File(dirPath);
//            if (!dir.exists()) {
//                if (dir.mkdirs()) {
//                    System.out.println("成功创建上传目录: " + dirPath);
//                } else {
//                    System.err.println("创建上传目录失败: " + dirPath);
//                }
//            }
//        }
//    }
//}
